#include "groupdeletedialog.h"
#include "ui_groupdeletedialog.h"

GroupDeleteDialog::GroupDeleteDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GroupDeleteDialog)
{
    ui->setupUi(this);
    m_pSettingManage = new SettingManage(this);
    ui->comboBoxModiGroup1->addItem("类型","type");
    ui->comboBoxModiGroup1->addItem("位置","location");
    connect(ui->btnOK,&QPushButton::clicked,this,[=](){
        this->accept();
    });
    connect(ui->btnCancel,&QPushButton::clicked,this,[=](){
        this->reject();
    });
    QString group1 = ui->comboBoxModiGroup1->currentData().toString();
    QVector<QString> batchValues = m_pSettingManage->readBatchKeys("Group", group1);
    QStringList comboItems = QStringList::fromVector(batchValues);
    ui->comboBoxModiGroup2->clear();
    ui->comboBoxModiGroup2->addItems(comboItems);

    connect(ui->comboBoxModiGroup1,QOverload<int>::of(&QComboBox::activated),this,[=](){
        QString group1 = ui->comboBoxModiGroup1->currentData().toString();
        QVector<QString> batchValues = m_pSettingManage->readBatchKeys("Group", group1);
        QStringList comboItems = QStringList::fromVector(batchValues);
        ui->comboBoxModiGroup2->clear();
        ui->comboBoxModiGroup2->addItems(comboItems);
    });
}

GroupDeleteDialog::~GroupDeleteDialog()
{
    delete ui;
}

QString GroupDeleteDialog::getCombox1Data()
{
    return ui->comboBoxModiGroup1->currentData().toString();
}

QString GroupDeleteDialog::getCombox2Data()
{
    return  ui->comboBoxModiGroup2->currentText();
}
